import request from '@/plugins/axios'
import qs from 'qs'
export default {
    //获取员工列表
  getYuangong(pageNow,pageShow) {
    return request({
      url: `/user/pageUsers/${pageNow}/${pageShow}`,
      method: 'get'
    })
  },
  //根据部门ID查询部门
  getPartName(ppartId) {
      return request({
        url: `/part/getPartById/${ppartId}`,
        method: 'get'
      })
  },
  //获取所有部门信息
  getAllPart(){
    return request({
        url: `/part/getAllPart`,
        method: 'get'
      })
  },
  //更新用户信息
  updateUser(arr){
    return request({
        url:'/user/updateUser',
        method:'post',
        data:qs.stringify({
            address:arr.address,
            fitstTime:arr.fitstTime,
            lastTime:arr.lastTime,
            id:arr.id,
            nickname:arr.nickname,
            username:arr.username,
            /* userId:this.managerInformation.userId, */
            partId:arr.partId,
            phoneNumber:arr.phoneNumber,
            sex:arr.sex,
            status:arr.status,
            isDeleted: 0,
            role:arr.role,
        })
    })
  },
  //冻结 启用 用户
  changeStatus(userStatus){
    return request({
        url: `/user/freezeUserById/${userStatus}`,
        method: 'post'
      })
  },
  //添加新用户
  addUser(arr) {
    return request({
        url:'/user/insertUser',
        method:'post',
        data:qs.stringify({
            address:arr.address,
            fitstTime:arr.fitstTime,
            lastTime:arr.lastTime,
            nickname:arr.nickname,
            username:arr.username,
            password:arr.password,
            partId:arr.partId,
            phoneNumber:arr.phoneNumber,
            sex:arr.sex,
            status:arr.status,
            isDeleted: 0,
            role:'1',
        })
    })
  },
  //删除用户
  deleteUser(id){
    return request({
        url:`/user/deleteUserById/${id}`,
        method:'delete',
    })
  },
  //获取分页部门信息
  getPartList(pageNow,pageShow){
      return request({
          url:`/part/partList/${pageNow}/${pageShow}`,
          method:'get'
      })
  },
  //更新部门数据
  updatePart(arr){
    return request({
        url:`/part/updatePart`,
        method:'post',
        data:qs.stringify({
            partId: arr.partId,
            partName: arr.partName,
            partDescription: arr.partDescription
            })
        })
    },
    //新增部门
    addPart(arr){
      return request({
          url:`/part/savePart`,
          method:'post',
          data:qs.stringify({
              partName: arr.partName,
              partDescription: arr.partDescription
              })
          })
      },
    //删除部门
  deletePart(id){
    return request({
        url:`/part/deletePart/${id}`,
        method:'delete',
    })
  },
  //查询用户
  searchUser(now,size,name) {
    return request({
      url: `/user/getSomeUsers`,
      method: 'get',
      params:{
        current: now,
        limit: size,
        username: name
      }
    })
  },
  //查询部门
  searchPart(now,size,name) {
    return request({
      url: `/part/getSomePart`,
      method: 'get',
      params:{
        current: now,
        limit: size,
        partName: name
      }
    })
  },
  //查询角色
  searchRole(now,size,name){
    return request({
      url: `/role/getSomeRole`,
      method: 'get',
      params:{
        current: now,
        limit: size,
        roleName: name
      }
    })
  },
  //获取角色列表
  getRole(pageNow,pageShow) {
    return request({
      url: `/role/roleList/${pageNow}/${pageShow}`,
      method: 'get'
    })
  },
  //更新角色
  updateRole(arr){
    return request({
      url:'/role/updateRole',
      method:'post',
      data:{
        roleDescription: arr.roleDescription,
        roleId: arr.roleId,
        roleName: arr.roleName
      }
    })
  },
  //新增角色
  addRole(arr){
    return request({
      url:'/role/saveRole',
      method:'post',
      data:{
        roleDescription: arr.roleDescription,
        roleName: arr.roleName
      }
    })
  },
  //删除角色
  deleteRole(id){
    return request({
      url:`/role/deleteRole/${id}`,
      method:'delete',
    })
  }
}